/**
 * Description: 登录
 *
 * @author      Eden
 * @datetime    2016/11/25 09:30
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

(function () {
    "use strict";

    var api = {
        applyCheckUrl: "/money/purchaser/apply"
    };

    sm.controller('admin-money-purchaser-check', ['$scope', '$http', 'Modal', function ($scope, $http, Modal) {

        $scope.year = GetQueryString('year');
        $scope.month = GetQueryString('month');

        $scope.submit = function () {
            if (!$scope.year || !$scope.month) {
                Modal.error('参数操作，非法操作');
                return false;
            }

            $http.post(api.applyCheckUrl, {
                year: $scope.year,
                month: $scope.month
            }).success(function (res) {
                if (res.state) {
                    Modal.alert({
                        title: "操作提示",
                        content: "对账申请成功，等待管理人员审核",
                        buttons: [{
                            name: "留在本页"
                        }, {
                            name: "查看历史",
                            event: function () {
                                location.href = "/money/history/index"
                            }
                        }]
                    });
                } else {
                    Modal.error(res.error ? res.error : "对账申请发送失败");
                }
            });
        };


    }]);

})();

